<template>
  <div class="title-wrapper">
    <div v-if="title" class="title">{{ myTitle }}</div>
    <slot name="rightOperator" class="operator"></slot>
  </div>
</template>

<script lang="ts" setup>
import { computed, defineProps } from 'vue'
import { useRoute } from 'vue-router'

const props = defineProps({
  title: {
    type: String,
    default: '',
  },
})

const route = useRoute()

const myTitle = computed(() => {
  if (!props.title) {
    return route.meta?.title
  }
  return props.title
})
</script>

<style lang="scss">
.title-wrapper {
  display: flex;
  height: 60px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 15px;
  border-bottom: 1px solid #4e5262;

  .title {
    padding-left: 12px;
    font-size: 14px;
    color: var(--color-base);
    border-left: 4px solid var(--color-primary);
  }
}
</style>
